// JavaScript Document

function convert(num)
{
	var out = "";
	var base = 10;
	var getBase = document.form.base;
	for (i = 0; i < getBase.length; i++)
		if (getBase[i].checked)
			base = getBase[i].value;
	while (num > 0)
	{
		if ((num % base) > 9)
		{
			switch(num % base) 
			{
				case 15:
					out = "F" + out;
					break;
				case 14:
					out = "E" + out;
					break;
				case 13:
					out = "D" + out;
					break;
				case 12:
					out = "C" + out;
					break;
				case 11:
					out = "B" + out;
					break;
				case 10:
					out = "A" + out;
					break;
			}
		}
		else 
		{
			out = (num % base) + out;
		}
		num = (num - (num % base)) / base;
	}
	var answer = "<p>" + out + "</p>";
	document.getElementById("ans").innerHTML = answer;
}